this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.UI=this.BX.Landing.UI||{};(function(e,t,n,i,a,o,s,r){"use strict";var c;var l=function(e){babelHelpers.inherits(t,e);function t(){var e;var n;babelHelpers.classCallCheck(this,t);for(var i=arguments.length,a=new Array(i),c=0;c<i;c++){a[c]=arguments[c]}n=babelHelpers.possibleConstructorReturn(this,(e=babelHelpers.getPrototypeOf(t)).call.apply(e,[this].concat(a)));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(n),"dictionary",null);n.setEventNamespace("BX.Landing.UI.Panel.IconPanel");n.setTitle(s.Loc.getMessage("LANDING_ICONS_SLIDER_TITLE"));r.Dom.addClass(n.layout,"landing-ui-panel-icon");r.Dom.addClass(n.overlay,"landing-ui-panel-icon");r.Dom.attr(n.layout,"hidden",true);r.Dom.attr(n.overlay,"hidden",true);n.resolver=function(){};n.iconList=null;n.search=r.Runtime.debounce(n.search,500).bind(babelHelpers.assertThisInitialized(n));n.searchField=new o.TextField({className:"landing-ui-panel-icon-search",placeholder:s.Loc.getMessage("LANDING_ICON_PANEL_INPUT_PLACEHOLDER"),textOnly:true,onInput:n.search});r.Dom.append(n.layout,window.parent.document.body);n.initDictionary();return n}babelHelpers.createClass(t,[{key:"initDictionary",value:function e(){var t=this;if(this.dictionary===null){this.dictionary={};var n=s.Loc.getMessage("LANGUAGE_ID");if(n!=="ru"&&n!=="de"){return}BX.ajax.loadJSON("/bitrix/js/landing/dicdata/"+n+".json",(function(e){babelHelpers.toConsumableArray(Object.keys(e)).map((function(n){e[n].toLowerCase().split(" ").map((function(e){if(e){t.dictionary[e]=n}}))}))}))}}},{key:"translateWord",value:function e(t){if(this!==null&&this!==void 0&&this.dictionary[t]){return this.dictionary[t]}return null}},{key:"selectDefaultCategory",value:function e(){if(this.defaultCategory){this.onCategoryChange(this.defaultCategory)}}},{key:"makeLayout",value:function e(){var i=this;if(r.Type.isStringFilled(this.content.innerHTML)){return}r.Dom.append(this.searchField.getLayout(),this.sidebar);t.getLibraries().then((function(e){e.forEach((function(e){var t=e.id,a=e.name,o=e.active,s=e.categories;if(o===false){return}if(!i.defaultCategory){i.defaultCategory=s[0].id}i.appendSidebarButton(new n.SidebarButton({id:t,text:a}));s.forEach((function(e){i.appendSidebarButton(new n.SidebarButton({id:e.id,text:e.name,onClick:i.onCategoryChange.bind(i,e.id),child:true}))}))}));i.selectDefaultCategory()}));this.appendFooterButton(new a.BaseButton("save_icon",{text:s.Loc.getMessage("LANDING_ICON_PANEL_BUTTON_CHOOSE"),onClick:function e(){if(i.iconList.getActiveIcon()){i.resolver({iconOptions:i.iconList.getActiveOptions(),iconClassName:i.iconList.getActiveIcon()})}void i.hide()},className:"landing-ui-button-content-save"}));this.appendFooterButton(new a.BaseButton("cancel_icon",{text:s.Loc.getMessage("LANDING_ICON_PANEL_BUTTON_CANCEL"),onClick:this.hide.bind(this),className:"landing-ui-button-content-cancel"}))}},{key:"fillIconsList",value:function e(t,n){var a=this;this.iconList=new i.IconListCard;this.iconList.setTitle(n);t.forEach((function(e){if(r.Type.isObject(e)){var t={options:e.options?e.options:{},defaultOption:e.defaultOption?e.defaultOption:""};a.iconList.addItem(e.className,t)}else{a.iconList.addItem(e)}}));this.appendCard(this.iconList)}},{key:"onCategoryChange",value:function e(n){var i=this;this.content.innerHTML="";if(this.sidebarButtons.getActive()){this.sidebarButtons.getActive().deactivate()}this.sidebarButtons.get(n).activate();t.getLibraries().then((function(e){e.forEach((function(e){if(e.active===false){return}e.categories.forEach((function(e){if(n===e.id){i.fillIconsList(e.items,e.name)}}))}))}))}},{key:"search",value:function e(n){var a=this;if(n.trim().length<2){this.selectDefaultCategory();return}this.content.innerHTML="";if(this.sidebarButtons.getActive()){this.sidebarButtons.getActive().deactivate()}t.getLibraries().then((function(e){var t=[];var o=new Intl.Collator(undefined,{usage:"search",sensitivity:"base",ignorePunctuation:true});var c=n.toLowerCase().trim().split(" ");if(c.length===0){return}e.forEach((function(e){if(e.active===false){return}e.categories.forEach((function(e){e.items.forEach((function(e){if(r.Type.isObject(e)&&e.keywords&&e.keywords!==""){var n=c.some((function(t){var n=a.translateWord(t);return e.keywords.split(" ").find((function(e){return o.compare(t,e)===0||o.compare(n,e)===0}))}));if(n){t.push(e)}}}))}))}));var l=s.Loc.getMessage("LANDING_ICON_PANEL_TITLE_RESULT").replace("@query@",n.trim());if(t.length>0){a.fillIconsList(t,l)}else{var d;a.iconList=new i.IconListCard;a.iconList.setTitle(l);if(!/^[a-zA-Z0-9]+$/.test(n)){d=a.getNotFoundMessage()}else{d=a.getNotFoundMessage()}r.Dom.append(d,a.iconList.getBody());a.appendCard(a.iconList)}}))}},{key:"getNotFoundMessage",value:function e(){return t.cache.remember("notFoundMsg",(function(){var e,n;var i=s.Loc.getMessage("LANGUAGE_ID");if(i===t.DEFAULT_LANG){e="LANDING_ICON_PANEL_NOT_FOUND_DEFAULT";n="--not_found"}else if(t.SUPPORTED_LANG.indexOf(i)!==-1){e="LANDING_ICON_PANEL_NOT_FOUND_SUPPORTED";n="--not_found"}else{e="LANDING_ICON_PANEL_NOT_FOUND_INCORRECT";n="--incorrect_lang"}return r.Tag.render(c||(c=babelHelpers.taggedTemplateLiteral(['<div class="landing-ui-panel-icon-not-found">\n\t\t\t\t<div class="landing-ui-panel-icon-not-found-image ','"></div>\n\t\t\t\t<div class="landing-ui-panel-icon-not-found-title">\n\t\t\t\t\t',"\n\t\t\t\t</div>\n\t\t\t</div>"])),n,s.Loc.getMessage(e))}))}},{key:"show",value:function e(){var n=this;return new Promise((function(e){n.resolver=e;n.makeLayout();void babelHelpers.get(babelHelpers.getPrototypeOf(t.prototype),"show",n).call(n)}))}}],[{key:"getInstance",value:function e(){if(!t.instance){t.instance=new t}return t.instance}},{key:"getLibraries",value:function e(){return t.cache.remember("libraries",(function(){return r.Runtime.loadExtension(["landing.icon.fontawesome","landing.icon.fontawesome6_brands","landing.icon.fontawesome6_1","landing.icon.fontawesome6_2","landing.icon.fontawesome6_3","landing.icon.etlineicons","landing.icon.hsicons","landing.icon.simpleline","landing.icon.simplelinepro1","landing.icon.simplelinepro2"]).then(Object.values)}))}}]);return t}(t.Content);babelHelpers.defineProperty(l,"SUPPORTED_LANG",["en","ru","de"]);babelHelpers.defineProperty(l,"DEFAULT_LANG","en");babelHelpers.defineProperty(l,"cache",new r.Cache.MemoryCache);e.IconPanel=l})(this.BX.Landing.UI.Panel=this.BX.Landing.UI.Panel||{},BX.Landing.UI.Panel,BX.Landing.UI.Button,BX.Landing.UI.Card,BX.Landing.UI.Button,BX.Landing.UI.Field,BX.Landing,BX);
//# sourceMappingURL=iconpanel.bundle.map.js